{extend name="base" /} {block name="css"}{/block} {block name="body"}
<div class="admin-main layui-form">
    <div class="layui-field-box">
        <div class="layui-box-searchber" style="overflow: visible">
            <a class="layui-btn layui-btn-sm" href="{:url('admin/article/add')}">新增文章</a>
            <button class="layui-btn layui-btn-normal layui-btn-sm" data-url="{:url('article/pullNew')}" lay-submit id="pullNew">同步资源</button>
            <button class="layui-btn layui-btn-danger layui-btn-sm" data-url="{:url('article/alldelete')}" lay-submit lay-filter="alldelete">删除选中</button>
            <div class="layui-form-pane">
            <form class="layui-form" action="{:url('admin/article/index')}" method="get">
                    <div class="layui-inline" style="width:100px">
                        <select name="category_id">
                                <option value="">栏目分类</option>
                                {volist name="category_level_list" id="vo"}
                                <option {if condition="$category_id eq $vo['id']"}selected="selected"{/if} value="{$vo.id}">{neq name="vo.level" value="1"}|{php}for($i=1;$i<$vo['level'];$i++){echo ' --';}{/php}{/neq}{$vo.name}</option>
                                {/volist}
                              </select>
                    </div>
                    <div class="layui-inline" style="width:100px">
                        <select name="status">
                                <option  value="">状态</option>
                                <option {if condition="$status eq '0'"}selected="selected"{/if} value="0">待审</option>
                                <option {if condition="$status eq 1"}selected="selected"{/if} value="1">正常</option>
                                <option {if condition="$status eq 2"}selected="selected"{/if} value="2">不通过</option>
                                <option {if condition="$status eq -1"}selected="selected"{/if} value="-1">关闭</option>
                              </select>
                    </div>
                    <div class="layui-inline" style="width:100px">
                        <input type="text" placeholder="开始日期" value="{$startdate}" name="startdate" class="layui-input" id="startdate">
                    </div>
                    <div class="layui-inline" style="width:100px">
                        <input type="text" placeholder="结束日期" value="{$enddate}" name="enddate" class="layui-input" id="enddate">
                    </div>
                    <div class="layui-inline" style="width:100px">
                        <select name="is_essence">
                                <option  value="">加精</option>
                                <option {if condition="$is_essence eq 1"}selected="selected"{/if} value="1">是精选</option>
                                <option {if condition="$is_essence eq '0'"}selected="selected"{/if} value="0">一般</option>
                              </select>
                    </div>
                    <div class="layui-inline" style="width:100px">
                        <select name="is_ad">
                                <option  value="">广告</option>
                                <option {if condition="$is_ad eq 1"}selected="selected"{/if} value="1">是广告</option>
                                <option {if condition="$is_ad eq '0'"}selected="selected"{/if} value="0">普通</option>
                              </select>
                    </div>
                <div class="layui-inline" style="width:100px">
                    <select name="is_carousel">
                        <option  value="">轮播</option>
                        <option {if condition="$is_carousel eq 1"}selected="selected"{/if} value="1">是轮播</option>
                        <option {if condition="$is_carousel eq '0'"}selected="selected"{/if} value="0">普通</option>
                    </select>
                </div>
                    <div class="layui-inline" style="width:100px">
                        <input type="text" name="keyword" value="{$keyword}" placeholder="关键词" class="layui-input">
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">每页条数</label>
                        <div class="layui-inline" style="width:50px"><input type="number" name="perpage" value="{$perpage}" title placeholder="每页条数" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-inline">
                        <button class="layui-btn  layui-btn-sm">搜索</button>
                    </div>
            </form>
        </div>
        </div>

        <hr>

        <table class="layui-table admin-table">
            <thead>
                <tr>
                    <th width="10px" align="center"><input type="checkbox" lay-skin="primary" name="checkAll" lay-filter="checkAll"></th>
                    <th width="40px" style="text-align:center">ID</th>
                    <th>文章标题</th>
                    <th width="60px" style="text-align:center">所属栏目</th>
                    <th width="60px" style="text-align:center">作者</th>
                    <th width="70px" style="text-align:center">状态</th>
                    <th width="60px" style="text-align:center">广告</th>
                    <th width="60px" style="text-align:center">加精</th>
                    <th width="60px" style="text-align:center">轮播</th>
                    <th width="80px" style="text-align:center">录入时间</th>
                    <th width="40px" style="text-align:center">奖励信息</th>
                    <th width="80px" style="text-align:center">审核发布时间</th>
                    <th width="110px" style="text-align:center">操作</th>
                </tr>
            </thead>
            <tbody id="content">
                {volist name="article_list" id="vo"}
                <tr>
                    <td align="center"><input type="checkbox" lay-skin="primary" name="ids[{$vo.id}]" lay-filter="checkOne" value="{$vo.id}"></td>
                    <td align="center">{$vo.id}</td>
                    <td style="padding-left: 20px;"><a target="_blank" href="{:routerurl('index/index/detail',array('id'=>$vo.id))}"><span style="color:{$vo.color}">{$vo.title|mb_substr=0,20,'utf-8'}</span>{if $vo.activity_finish_time}<br>结束时间：{$vo.activity_finish_time}{/if}</a></td>
                    <td align="center"><a href="{:url('admin/article/index')}?category_id={$vo.category_id}">{$vo.name}</a></td>
                    <td align="center">{$vo.username}</td>
                    <td align="center">
                        {if $vo.status eq 0}<span style="padding:5px;color:#FFF;background:green">待审</span>{elseif $vo.status eq 1}正常 {elseif $vo.status eq 2}<span style="padding:5px;color:#FFF;background:red">不通过</span>{else /}<span style="padding:5px;color:#FFF;background:grey">隐藏</span>                        {/if}
                    </td>
                    <td align="center">
                        <input type="checkbox" lay-skin="switch" lay-text="广告|广告" data-column="is_ad" lay-filter="switchSet" value="{$vo['id']}" {php}echo $vo[ 'is_ad']==1 ? 'checked' : '';{/php}>
                    </td>
                    <td align="center">
                        <input type="checkbox" lay-skin="switch" lay-text="精选|精选" data-column="is_essence" lay-filter="switchSet"  value="{$vo['id']}" {php}echo $vo[ 'is_essence']==1 ? 'checked' : '';{/php}>
                    </td>
                    <td align="center">
                        <input type="checkbox" lay-skin="switch" lay-text="轮播|轮播" data-column="is_carousel" lay-filter="switchSet"  value="{$vo['id']}" {php}echo $vo[ 'is_carousel']==1 ? 'checked' : '';{/php}>
                    </td>
                    <td align="center">{$vo.created_at}</td>
                    <td align="center">{if $vo.reward_status neq -1}有{/if}</td>
                    <td align="center">{$vo.publish_time}</td>
                    <td align="center">
                        <a class="layui-btn layui-btn-normal layui-btn-sm" href="{:url('article/edit',array('id'=>$vo['id']))}">编审</a>
                        <a class="elementdel layui-btn layui-btn-danger layui-btn-sm" href="javascript:;" data-id="{$vo.id}" data-url="{:url('admin/article/delete',array('id'=>$vo['id']))}" title="删除">删除</a>
                    </td>
                </tr>
                {/volist}
            </tbody>
        </table>
    </div>


</div>
{/block} {block name="page"}
<div class="btable-paged">
    <div class="formbtngroup">
        {$article_list->render()}
    </div>
</div>
{/block} {block name="js"}
<script type="text/javascript" src="__ADMIN__/js/delelement.js"></script>
{/block} {block name="script"}

<script>
    layui.use(['form', 'laydate'], function() {
        var form = layui.form,
            laydate = layui.laydate,
            $form = $('form'),
            jq = layui.jquery;
        form.on('select()', function(data) {
            $form.submit();
        });

        laydate.render({
            elem: '#startdate' //指定元素
                ,
            done: function(value, date) {
                $form.submit();
            }
        });
        laydate.render({
            elem: '#enddate' //指定元素
                ,
            done: function(value, date) {
                $form.submit();
            }
        });
        $("#pullNew").on('click', function() {
                var url = $(this).data('url');
                    jq.get(url,
                        function(res) {

                                layer.msg(res.msg, {
                                    icon: 1,
                                    time: 1000
                                },function () {
                                    location.reload();
                                });

                        });
            });
        var status = 0;
        form.on('switch(switchSet)', function(data) {
            loading = layer.load(2, {
                shade: [0.2, '#000']
            });
            var column=jq(this).data('column');
            if (data.elem.checked) {
                status = 1;
            } else {
                status = 0;
            }
            var url = "{:url('admin/article/toggle')}?id=" + data.value + '&status=' + status + '&name='+column;
            jq.get(url, function(data) {

                if (data.code == 200) {
                    layer.close(loading);
                    layer.msg(data.msg, {
                        icon: 1,
                        time: 1000
                    });
                } else {
                    layer.close(loading);
                    layer.msg(data.msg, {
                        icon: 2,
                        anim: 6,
                        time: 1000
                    });
                }
            });
            return false;
        });
    })
</script>
{/block}